//
//  Statistics3PLDetailCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2021/6/25.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "Statistics3PLDetailCell.h"

@interface Statistics3PLDetailCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *title1Lab;
@property (nonatomic, strong) UILabel *content1Lab;
@property (nonatomic, strong) UILabel *lineLab;
@property (nonatomic, strong) UILabel *title2Lab;
@property (nonatomic, strong) UILabel *content2Lab;
@property (nonatomic, strong) UILabel *title3Lab;
@property (nonatomic, strong) UILabel *content3Lab;
@property (nonatomic, strong) UILabel *title4Lab;
@property (nonatomic, strong) UILabel *content4Lab;
@property (nonatomic, strong) UILabel *title5Lab;
@property (nonatomic, strong) UILabel *content5Lab;
@property (nonatomic, strong) UILabel *title6Lab;
@property (nonatomic, strong) UILabel *content6Lab;
@property (nonatomic, strong) UILabel *title7Lab;
@property (nonatomic, strong) UILabel *content7Lab;
@property (nonatomic, strong) UILabel *title8Lab;
@property (nonatomic, strong) UILabel *content8Lab;

@end

@implementation Statistics3PLDetailCell

+ (instancetype)Statistics3PLDetailCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"Statistics3PLDetailCell";
    Statistics3PLDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[Statistics3PLDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [UIView new];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.title1Lab = [UILabel new];
        self.title1Lab.textColor = HexColor(0x707070);
        self.title1Lab.font = BoldFontOfSize(17);
        [self.bgView addSubview:self.title1Lab];
        
        self.content1Lab = [UILabel new];
        self.content1Lab.textColor = HexColor(0x707070);
        self.content1Lab.font = [UIFont systemFontOfSize:13];
        self.content1Lab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.content1Lab];
        
        self.lineLab = [UILabel new];
        self.lineLab.backgroundColor = HexColorA(0x707070, 0.1);
        [self.bgView addSubview:self.lineLab];
        
        self.title2Lab = [UILabel new];
        self.title2Lab.textColor = HexColor(0x707070);
        self.title2Lab.font = BoldFontOfSize(17);
        [self.bgView addSubview:self.title2Lab];
        
        self.content2Lab = [UILabel new];
        self.content2Lab.textColor = HexColor(0x707070);
        self.content2Lab.font = [UIFont systemFontOfSize:13];
        self.content2Lab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.content2Lab];
        
        self.title3Lab = [UILabel new];
        self.title3Lab.textColor = HexColor(0x707070);
        self.title3Lab.font = BoldFontOfSize(17);
        [self.bgView addSubview:self.title3Lab];
        
        self.content3Lab = [UILabel new];
        self.content3Lab.textColor = HexColor(0x707070);
        self.content3Lab.font = [UIFont systemFontOfSize:13];
        self.content3Lab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.content3Lab];
        
        self.title4Lab = [UILabel new];
        self.title4Lab.textColor = HexColor(0x707070);
        self.title4Lab.font = BoldFontOfSize(17);
        [self.bgView addSubview:self.title4Lab];
        
        self.content4Lab = [UILabel new];
        self.content4Lab.textColor = HexColor(0x707070);
        self.content4Lab.font = [UIFont systemFontOfSize:13];
        self.content4Lab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.content4Lab];
        
        self.title5Lab = [UILabel new];
        self.title5Lab.textColor = HexColor(0x707070);
        self.title5Lab.font = BoldFontOfSize(17);
        [self.bgView addSubview:self.title5Lab];
        
        self.content5Lab = [UILabel new];
        self.content5Lab.textColor = HexColor(0x707070);
        self.content5Lab.font = [UIFont systemFontOfSize:13];
        self.content5Lab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.content5Lab];
        
        self.title6Lab = [UILabel new];
        self.title6Lab.textColor = HexColor(0x707070);
        self.title6Lab.font = BoldFontOfSize(17);
        [self.bgView addSubview:self.title6Lab];
        
        self.content6Lab = [UILabel new];
        self.content6Lab.textColor = HexColor(0x707070);
        self.content6Lab.font = [UIFont systemFontOfSize:13];
        self.content6Lab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.content6Lab];
        
        self.title7Lab = [UILabel new];
        self.title7Lab.textColor = HexColor(0x707070);
        self.title7Lab.font = BoldFontOfSize(17);
        [self.bgView addSubview:self.title7Lab];
        
        self.content7Lab = [UILabel new];
        self.content7Lab.textColor = HexColor(0x707070);
        self.content7Lab.font = [UIFont systemFontOfSize:13];
        self.content7Lab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.content7Lab];
        
        self.title8Lab = [UILabel new];
        self.title8Lab.textColor = HexColor(0x707070);
        self.title8Lab.font = BoldFontOfSize(17);
        [self.bgView addSubview:self.title8Lab];
        
        self.content8Lab = [UILabel new];
        self.content8Lab.textColor = HexColor(0x707070);
        self.content8Lab.font = [UIFont systemFontOfSize:13];
        self.content8Lab.numberOfLines = 0;
        [self.bgView addSubview:self.content8Lab];
    }
    return self;
}

-(void)setModel:(Statistics3PLModel *)model {
    _model = model;
    [self configUI];
}

- (void)configUI {
    self.bgView.nim_left = 15;
    self.bgView.nim_top = 15;
    self.bgView.nim_width = ScreenW - 30;
    
    self.title1Lab.text = @"地址";
    [self.title1Lab sizeToFit];
    self.title1Lab.nim_left = 15;
    self.title1Lab.nim_top = 15;
    
    self.content1Lab.text = self.model.addressDetail;
    self.content1Lab.nim_width = self.bgView.nim_width - 15 - self.title1Lab.nim_right - 15;
    [self.content1Lab sizeToFit];
    self.content1Lab.nim_left = self.bgView.nim_width - 15 - self.content1Lab.nim_width;
    if (self.content1Lab.nim_height > self.title1Lab.nim_height) {
        self.content1Lab.nim_top = self.title1Lab.nim_top;
    }else {
        self.content1Lab.nim_centerY = self.title1Lab.nim_centerY;
    }
    
    self.lineLab.nim_left = self.title1Lab.nim_left;
    self.lineLab.nim_top = self.content1Lab.nim_height ? self.content1Lab.nim_bottom + 7 : self.title1Lab.nim_bottom + 7;
    
    self.title2Lab.text = @"联系人";
    self.title2Lab.nim_left = self.title1Lab.nim_left;
    self.title2Lab.nim_top = self.lineLab.nim_bottom + 15;
    [self.title2Lab sizeToFit];
    
    self.content2Lab.text = self.model.name;
    [self.content2Lab sizeToFit];
    self.content2Lab.nim_left = self.title2Lab.nim_right + 15;
    self.content2Lab.nim_width = self.bgView.nim_width - 15 - self.content2Lab.nim_left;
    self.content2Lab.nim_centerY = self.title2Lab.nim_centerY;
    
    self.title3Lab.text = @"联系电话";
    self.title3Lab.nim_left = self.title1Lab.nim_left;
    self.title3Lab.nim_top = self.title2Lab.nim_bottom + 22;
    [self.title3Lab sizeToFit];
    
    self.content3Lab.text = self.model.mobile;
    [self.content3Lab sizeToFit];
    self.content3Lab.nim_left = self.title3Lab.nim_right + 15;
    self.content3Lab.nim_width = self.bgView.nim_width - 15 - self.content3Lab.nim_left;
    self.content3Lab.nim_centerY = self.title3Lab.nim_centerY;
    
    self.title4Lab.text = @"注册资金";
    self.title4Lab.nim_left = self.title1Lab.nim_left;
    self.title4Lab.nim_top = self.title3Lab.nim_bottom + 22;
    [self.title4Lab sizeToFit];
    
    self.content4Lab.text = self.model.register_fund;
    [self.content4Lab sizeToFit];
    self.content4Lab.nim_left = self.title4Lab.nim_right + 15;
    self.content4Lab.nim_width = self.bgView.nim_width - 15 - self.content4Lab.nim_left;
    self.content4Lab.nim_centerY = self.title4Lab.nim_centerY;
    
    self.title5Lab.text = @"员工人数";
    self.title5Lab.nim_left = self.title1Lab.nim_left;
    self.title5Lab.nim_top = self.title4Lab.nim_bottom + 22;
    [self.title5Lab sizeToFit];
    
    self.content5Lab.text = self.model.worker_num;
    [self.content5Lab sizeToFit];
    self.content5Lab.nim_left = self.title5Lab.nim_right + 15;
    self.content5Lab.nim_width = self.bgView.nim_width - 15 - self.content5Lab.nim_left;
    self.content5Lab.nim_centerY = self.title5Lab.nim_centerY;
    
    self.title6Lab.text = @"仓储面积";
    self.title6Lab.nim_left = self.title1Lab.nim_left;
    self.title6Lab.nim_top = self.title5Lab.nim_bottom + 22;
    [self.title6Lab sizeToFit];
    
    self.content6Lab.text = self.model.area;
    [self.content6Lab sizeToFit];
    self.content6Lab.nim_left = self.title6Lab.nim_right + 15;
    self.content6Lab.nim_width = self.bgView.nim_width - 15 - self.content6Lab.nim_left;
    self.content6Lab.nim_centerY = self.title6Lab.nim_centerY;
    
    self.title7Lab.text = @"车辆数量";
    self.title7Lab.nim_left = self.title1Lab.nim_left;
    self.title7Lab.nim_top = self.title6Lab.nim_bottom + 22;
    [self.title7Lab sizeToFit];
    
    self.content7Lab.text = self.model.car_num;
    [self.content7Lab sizeToFit];
    self.content7Lab.nim_left = self.title7Lab.nim_right + 15;
    self.content7Lab.nim_width = self.bgView.nim_width - 15 - self.content7Lab.nim_left;
    self.content7Lab.nim_centerY = self.title7Lab.nim_centerY;
    
    self.title8Lab.text = @"企业简介：";
    self.title8Lab.nim_left = self.title1Lab.nim_left;
    self.title8Lab.nim_top = self.title7Lab.nim_bottom + 22;
    [self.title8Lab sizeToFit];
    
    self.content8Lab.text = self.model.info;
    self.content8Lab.nim_left = self.title1Lab.nim_left;
    self.content8Lab.nim_width = self.bgView.nim_width - 15 - 15;
    self.content8Lab.nim_top = self.title8Lab.nim_bottom + 22;
    [self.content8Lab sizeToFit];
    
    self.bgView.nim_height = self.content8Lab.nim_bottom + 50;
    self.height = self.bgView.nim_bottom;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
